﻿@model KL.Store.Web.Models.ProductsModel
@using KL.Store.Core;
@if (Model != null && Model.RelatedProducts != null && Model.RelatedProducts.Count > 0 && Parameters.Theme != "HA")
{
    <div class="block special-products">
        <div class="special-products-row">
            <div class="special-products-inner">
                <div class="special-products-content">
                    <div class="special-products-slider">
                        @{var specialProductCount = 1;}
                        @foreach (var item in Model.RelatedProducts)
                        {
                            if (specialProductCount == 1)
                            {
                            @(new HtmlString("<div class=\"special-section\"><ul>"))
                            }
                            <li>
                                <a href="@item.LinkUrl">
                                    @if (item.ProductImageCount > 0)
                                    {
                                        <img id="bpi_@item.ProductId" src="@(Parameters.WebSiteImageUrl)/product-medium/@(item.ProductId)_1_s.jpg" alt="@(item.ProductName.Replace("\"", ""))" />
                                    }
                                    else
                                    {
                                        <img id="bpi_@item.ProductId" src="/Images/@Parameters.Theme/product-image-not-found-200x.jpg" alt="@(item.ProductName.Replace("\"", ""))" />
                                    }
                                    <p class="product-name"><span>@item.ProductName</span></p>
                                    @{
                                    var readPrice = "";
                                    if (item.SpecialPrice > 0)
                                    {
                                        readPrice = item.SpecialPrice.ToString("###,###,##0.00") + " " + item.Currency;
                                    }
                                    else
                                    {
                                        readPrice = item.Price.ToString("###,###,##0.00") + " " + item.Currency;
                                    }                                       
                                    }
                                    <p class="product-price">@readPrice</p>
                                </a>
                            </li>
                                    if (specialProductCount == Model.RelatedProducts.Count)
                                    {
                            @(new HtmlString("</ul></div>"))
                                    }
                                    else if (specialProductCount % 4 == 0)
                                    {
                            @(new HtmlString("</ul></div><div class=\"special-section\"><ul>"))
                                    }
                                    specialProductCount++;
                        }
                    </div>
                    @if (Model.RelatedProducts.Count() > 4)
                    {
                        <script type="text/javascript">
                            $(document).ready(function () {
                                $(".special-products-slider").slidesjs({
                                    width: 100,
                                    height: 835,
                                    pagination: {
                                        active: false
                                    },
                                    navigation: {
                                        active: true,
                                        effect: "slide"
                                    },
                                    play: {
                                        active: false,
                                        effect: "slide",
                                        interval: 5000,
                                        auto: true,
                                        swap: false,
                                        pauseOnHover: true,
                                        restartDelay: 4500
                                    }
                                });
                                $("a.slidesjs-navigation").html("");
                            });
                        </script>
                    }
                </div>
            </div>
            <div class="clearfix"></div>
        </div>
        <div class="special-products-title">Günün Fırsatları</div>
    </div>
}